package com.p2l.letterblocks;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;

public class Obstacle extends Sprite {
	
	public Obstacle(float x, float y, float height, float width, Bitmap bitmap) {
		super(x, y, height, width, bitmap);
		setHeight(height);
		setWidth(width);
	}
	
	@Override
	public void onDraw(Canvas c, int delta, float x) {
		float newY = getY() + (getVector().getY() * delta);
		Rect r = new Rect((int)(getX() - x), (int)(newY), (int)(getX() - x + getWidth()), (int)(newY + getHeight()));
		c.drawBitmap(getBitmap(), null, r, getPaint());
	}
	
	public boolean isColliding(Sprite s) {
		if (getX() <= s.getX() + s.getWidth() && getX() + getWidth() >= s.getX() && getY() <= s.getY() + s.getHeight() && getY() + getHeight() >= s.getY())
			return true;
		else
			return false;
	}
}